#!/bin/bash

# Yao Framework 快速验证脚本
# 快速验证核心功能是否正常工作

set -e

# 颜色定义
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

echo -e "${BLUE}🚀 Yao Framework 快速验证${NC}"
echo "==============================="

# 1. 检查编译
echo -e "${BLUE}1. 检查项目编译...${NC}"
if cjpm build > /dev/null 2>&1; then
    echo -e "${GREEN}✅ 编译成功${NC}"
else
    echo -e "${RED}❌ 编译失败${NC}"
    exit 1
fi

# 2. 验证AI Agent核心功能
echo -e "${BLUE}2. 验证AI Agent核心功能...${NC}"
if timeout 60 ./target/release/bin/yao.examples.ai_agent_validation > /dev/null 2>&1; then
    echo -e "${GREEN}✅ AI Agent验证成功${NC}"
else
    echo -e "${YELLOW}⚠️ AI Agent验证超时或失败${NC}"
fi

# 3. 验证函数式API
echo -e "${BLUE}3. 验证函数式API和宏功能...${NC}"
if timeout 120 ./target/release/bin/yao.examples > /dev/null 2>&1; then
    echo -e "${GREEN}✅ 函数式API验证成功${NC}"
else
    echo -e "${YELLOW}⚠️ 函数式API验证超时或失败${NC}"
fi

# 4. 验证Provider系统
echo -e "${BLUE}4. 验证Provider系统...${NC}"
if timeout 30 ./target/release/bin/yao.examples.providers > /dev/null 2>&1; then
    echo -e "${GREEN}✅ Provider系统验证成功${NC}"
else
    echo -e "${YELLOW}⚠️ Provider系统验证失败${NC}"
fi

# 5. 验证DSL功能
echo -e "${BLUE}5. 验证DSL功能...${NC}"
if timeout 30 ./target/release/bin/yao.examples.dsl > /dev/null 2>&1; then
    echo -e "${GREEN}✅ DSL功能验证成功${NC}"
else
    echo -e "${YELLOW}⚠️ DSL功能验证失败${NC}"
fi

echo "==============================="
echo -e "${GREEN}🎉 快速验证完成！${NC}"
echo ""
echo "如需详细验证，请运行："
echo "  ./scripts/run_verification_tests.sh"
echo ""
echo "如需查看详细输出，请直接运行示例："
echo "  ./target/release/bin/yao.examples.ai_agent_validation"
echo "  ./target/release/bin/yao.examples"
